﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Runtime.Serialization;

namespace ChatDLuXService.Model
{
    [DataContract (IsReference = true)]
    public class Room
    {
        private long _roomID = 0;//initialized to zero, if zero later then error occured
        private string _roomName;
        private string _roomDesc;
        private Dictionary<long, User> _userList;

        [DataMember]
        public long RoomID
        {
            get { return _roomID; }
            set { _roomID = value; }
        }

        [DataMember]
        public string RoomName
        {
            get { return _roomName; }
            set { _roomName = value; }
        }
        
        [DataMember]
        public string RoomDesc
        {
            get { return _roomDesc; }
            set { _roomDesc = value; }            
        }

        [DataMember]
        public Dictionary<long, User> UserList
        {
            get { return _userList; }
            set { _userList = value; }
        }

        //no arg constructor        
        public Room()
        { 
            _roomID = 0;
            _roomName = "";
            _roomDesc = "";
        }

        public Room(long roomID, string roomName, string roomDescription, User user)
        {
            _roomID = roomID;
            _roomName = roomName;
            _roomDesc = roomDescription;
            _userList.Add(user.PkId, user);
        }

        public void AddUser(User user)
        {
            _userList.Add(user.PkId, user);
        }
    }
}